import urllib

from celery import Celery
import  os

RABBITMQ_HOST = os.getenv('RABBITMQ_HOST', 'localhost')
RABBITMQ_PORT = os.getenv('RABBITMQ_PORT', '5672')
RABBITMQ_USER = os.getenv('RABBITMQ_USER', 'guest')
RABBITMQ_PASSWORD = os.getenv('RABBITMQ_PASSWORD', 'guest')
RABBITMQ_VHOST = os.getenv('RABBITMQ_VHOST', '/')
encoded_vhost = urllib.parse.quote(RABBITMQ_VHOST, safe='')

CELERY_BROKER_URL = f'amqp://{RABBITMQ_USER}:{RABBITMQ_PASSWORD}@{RABBITMQ_HOST}:{RABBITMQ_PORT}/{encoded_vhost}'
CELERY_RESULT_BACKEND = 'rpc://'  # 或使用 Redis、数据库等

print(CELERY_BROKER_URL)

celery_app = Celery(
    'bk_core',
    broker = CELERY_BROKER_URL,
    include=['core.task']
)

